package com.github.hook;

import android.text.TextUtils;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class Ndf456$dfan$sdfsg {
    public static boolean isAvailable() {
        return isAvailableByDns() || isAvailableByPing(null);
    }

    public static boolean isAvailableByDns() {
        return isAvailableByDns("");
    }

    public static boolean isAvailableByDns(final String domain) {
        final String realDomain = TextUtils.isEmpty(domain) ? "www.baidu.com" : domain;
        InetAddress inetAddress;
        try {
            inetAddress = InetAddress.getByName(realDomain);
            return inetAddress != null;
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        return false;
    }

    public static boolean isAvailableByPing(final String ip) {
        final String realIp = TextUtils.isEmpty(ip) ? "223.5.5.5" : ip;
        SSdgerg9fg6574ghs.Cdf97a43ga result = SSdgerg9fg6574ghs.eadfg74637a5ha(String.format("ping -c 1 %s", realIp), false);
        return result.result == 0;
    }
}
